// pages/mine/mine.js
const app = getApp();
var router = require("../../router.js");
Page({
  /**
   * 页面的初始数据
   */
  topage(e) {
    let path = e.currentTarget.dataset.path ; 
    if(path=='phone'){
      wx.makePhoneCall({
        phoneNumber: '40088880088' //仅为示例，并非真实的电话号码
      })
      return;
    }
    app.navTo(path)   
  },
  // 底部
  index: function () {
    app.radTo('../index/index')
  },
  underLine: function () {
    app.radTo('../underLine/underLine')
  },
  course: function () {
    app.radTo('../course/course')
  },
  distribution: function () {
    app.radTo('../distribution/distribution')
  },
  mine: function () {
    app.radTo('../mine/mine')
  },
  go_vip(e){
    let index = e.currentTarget.dataset.index;    
    wx.navigateTo({
      url: '../to_vip/to_vip?type=' + index,
    })
  },
  data: {
    list:[
      {
        src:"../../image/list_1.png",
        name:"我的保险",
        path:"../mysafe/mysafe"
      },
      {
        src: "../../image/list_2.png",
        name: "我的收入",
        path: "../mysale/mysale"
      },
      {
        src: "../../image/list_3.png",
        name: "我的报名",
        path: "../my_bm/my_bm"
      },
      {
        src: "../../image/list_4.png",
        name: "卡包",
        path: "../mycard/mycard"
      },
      {
        src: "../../image/list_5.png",
        name: "我的课程",
        path: "../mycourse/mycourse"
      },
  
      {
        src: "../../image/list_9.png",
        name: "资料编辑",
        path: "../edit_user_info/edit_user_info"
      },
      {
        src: "../../image/list_10.png",
        name: "客服",
        path: "phone"        
      },
 
    ],
    gradeList: [
      '普通会员',
      'VIP会员',
      '黄金VIP会员'
    ]
    
  },
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
     
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    app.isLogin();
    var that = this;
    app.request({
      url: router.user.info,
      method: "POST",
      data:{
        userId: wx.getStorageSync('userInfo')['id']
      },
      success: function (data) {
        console.log(data)
        that.setData({
          name: data.user_list.nickname,
          icon: data.user_list.head,
          grade: data.user_list.grade,
        });    
      }
    })
  }
})